#include <QtGui> 
#include "myqtapp.h"
#include "Functie.cpp"
// including <QtGui> saves us to include every class user, <QString>, <QFileDialog>,...

myQtApp::myQtApp()
{
	setupUi(this); // this sets up GUI


	connect( pushButton_do, SIGNAL( clicked() ), this, SLOT( doSomething() ) ); 
	connect( pushButton_clear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 
	connect( pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) ); 
}

void myQtApp::doSomething()
{
	QString str=lineEdit->text();
	const char *ch;
	ch=str.toStdString().c_str();
	Functie f(ch);

	char* data = f.derivata();
	QString str1;
	str1=data;

	QString strToDouble=lineEdit2->text();
	double valoare;
	valoare=strToDouble.toDouble();
	double valx=f.calculezDerivata(valoare);
	QString st = QString::number(valx);
	
	QString strToDouble1=lineEdit3->text();
	double valoare1;
	valoare1=strToDouble1.toDouble();
	double valx1=f.calculezValoare(valoare1);
	QString st1 = QString::number(valx1);

	textEdit->append( "Functia introdusa de tine este: " + lineEdit->text() );
	

	textEdit->append( "Derivata lui "+lineEdit->text()+ " este : " + str1 );
	textEdit->append( "Derivata in punctul "+lineEdit2->text()+ " este : "+ st );
	textEdit->append( "Valoarea functiei in punctul "+lineEdit3->text()+" este : "+st1);
}


void myQtApp::clear()
{
	textEdit->clear();
}


void myQtApp::about() 
{
	QMessageBox::about(this, "About","@Popa");
}


